home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / misc / math / MathFX_src.lha / fx3zz.c < prev    next >
C/C++ Source or Header  |  1995-12-20  |  2KB  |  75 lines

  1. /* Draws the next zig-zag line for a 3-d plot. The data is stored in */
  2. /* array z(*,ly) as a function of x() and y(). The subarray */
  3. /* z(1:nx,1:ny) is plotted out, starting at index (xstar0,ystar0). */
  4. /* Depending on the state of "flg0", the sequence of data points */
  5. /* sent to plnxtv is altered so as to allow cross-hatch plotting, */
  6. /* or plotting parallel to either the x-axis or the y-axis. */
  7.  
  8. #include "mathfx.h"
  9.  
  10. void fxt3zz(xstar0,ystar0,dx,dy,flg0,init,x,y,z,ly,nx,ny,u,v)
  11. int xstar0, ystar0, dx, dy, flg0, ly, nx, ny, init;
  12. float x[], y[], *z;
  13. int u[], v[];
  14. {
  15.       int flag;
  16.       int n;
  17.       int xstart, ystart;
  18.  
  19.       n = 0;
  20.       xstart = xstar0;
  21.       ystart = ystar0;
  22.       flag = flg0;
  23.       
  24. lab1:
  25.       if (1 <= xstart && xstart <= nx && 1 <= ystart && ystart <= ny) {
  26.         u[n] = wcpcx(w3wcx(x[xstart-1],y[ystart-1],
  27.                       *(z+(xstart-1)*ly+(ystart-1))));
  28.         v[n] = wcpcy(w3wcy(x[xstart-1],y[ystart-1],
  29.                       *(z+(xstart-1)*ly+(ystart-1))));
  30.         if (flag == -3) {
  31.           ystart = ystart + dy;
  32.           flag = -flag;
  33.         }
  34.         else if (flag == -2) 
  35.           ystart = ystart + dy;
  36.         else if (flag == -1) {
  37.           ystart = ystart + dy;
  38.           flag = 1;
  39.         }
  40.         else if (flag == 1)
  41.           xstart = xstart + dx;
  42.         else if (flag == 2)  {
  43.           xstart = xstart + dx;
  44.           flag = -2;
  45.         }
  46.         else if (flag == 3) {
  47.           xstart = xstart + dx;
  48.           flag = -flag;
  49.         }
  50.         n = n+1;
  51.         goto lab1;
  52.       }
  53.  
  54.       if (flag == 1 || flag == -2) {
  55.         if (flag == 1) {
  56.           xstart = xstart - dx;
  57.           ystart = ystart + dy;
  58.         }
  59.         else if (flag == -2) {
  60.           ystart = ystart - dy;
  61.           xstart = xstart + dx;
  62.         }
  63.  
  64.         if (1 <= xstart && xstart <= nx  && 1 <= ystart && ystart <= ny) {
  65.           u[n] = wcpcx(w3wcx(x[xstart-1],y[ystart-1],
  66.                        *(z+(xstart-1)*ly+(ystart-1))));
  67.           v[n] = wcpcy(w3wcy(x[xstart-1],y[ystart-1],
  68.                        *(z+(xstart-1)*ly+(ystart-1))));
  69.           n = n+1;
  70.         }
  71.  
  72.       }        
  73.       fxnxtv(u,v,n,init);
  74. }
  75.